package com.cskaoyan.app.service.impl;

import com.cskaoyan.app.bean.po.MarketGoods;
import com.cskaoyan.app.bean.po.MarketGoodsAttribute;
import com.cskaoyan.app.bean.po.MarketGoodsProduct;
import com.cskaoyan.app.bean.po.MarketGoodsSpecification;
import com.cskaoyan.app.mapper.MarketGoodsAttributeMapper;
import com.cskaoyan.app.mapper.MarketGoodsMapper;
import com.cskaoyan.app.mapper.MarketGoodsProductMapper;
import com.cskaoyan.app.mapper.MarketGoodsSpecificationMapper;
import com.cskaoyan.app.service.AdminGoodsCreateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminGoodsCreateServiceImpl implements AdminGoodsCreateService {
    @Autowired
    MarketGoodsMapper marketGoodsMapper;
    @Autowired
    MarketGoodsAttributeMapper marketGoodsAttributeMapper;
    @Autowired
    MarketGoodsProductMapper marketGoodsProductMapper;
    @Autowired
    MarketGoodsSpecificationMapper marketGoodsSpecificationMapper;

    @Override
    public void insertGoods(MarketGoods goods) {
        marketGoodsMapper.insertSelective(goods);
    }

    @Override
    public void insertAttribute(List<MarketGoodsAttribute> attributes) {
        for (MarketGoodsAttribute attribute : attributes) {
            marketGoodsAttributeMapper.insertSelective(attribute);
        }
    }

    @Override
    public void insertProduct(List<MarketGoodsProduct> products) {
        for (MarketGoodsProduct product : products) {
            marketGoodsProductMapper.insertSelective(product);

        }
    }

    @Override
    public void insertSpecification(List<MarketGoodsSpecification> specifications) {
        for (MarketGoodsSpecification specification : specifications) {

            marketGoodsSpecificationMapper.insertSelective(specification);
        }
    }
}
